import request from '@/utils/request'
// 获取员工负责人
export const reqGetEmployeeSimple = () => request.get('/sys/user/simple')

// 获取员工综合列表
export const reqGetEmployeeList = (page, size) => request.get('sys/user', { params: { page, size }})

// 删除员工
export const reqDelEmployee = id => request.delete(`/sys/user/${id}`)

// 新增员工
export const reqAddEmployee = data => request.post('/sys/user', data)

// 批量导入员工
export const reqImportEmployee = data => request.post('/sys/user/batch', data)

// 保存员工基本信息
export const reqSaveUserDetailById = data => request.put(`/sys/user/${data.id}`, data)

export const reqGetUserDetailById = id => request.get(`/sys/user/${id}`)

/** *
 *  读取用户详情的基础信息 (个人详情-下面的接口)
 * **/
export function reqGetPersonalDetail(id) {
  return request({
    method: 'get',
    url: `/employees/${id}/personalInfo`
  })
}

/** *
 *  更新用户详情的基础信息 (个人详情-下面的接口)
 * **/
export function reqUpdatePersonal(data) {
  return request({
    method: 'put',
    url: `/employees/${data.userId}/personalInfo`,
    data
  })
}

/** **
 * 获取用户的岗位信息  (岗位信息)
 * ****/
export function reqGetJobDetail(id) {
  return request({
    method: 'get',
    url: `/employees/${id}/jobs`
  })
}

/**
 * 保存岗位信息  (岗位信息)
 * ****/
export function reqUpdateJob(data) {
  return request({
    method: 'put',
    url: `/employees/${data.userId}/jobs`,
    data
  })
}

/** *
 * 给员工分配角色
 * ***/
export function reqAssignRoles(data) {
  return request({
    url: '/sys/user/assignRoles',
    data,
    method: 'put'
  })
}
